all_attributes = ["water", "fire", "ice", "lightning", "wind", "dark", "light", "grass", "stone", "sky"]

class Attribute:
    # 直接存储属性间的伤害倍数：键为当前属性，值为{目标属性: 倍数}
    # 2表示克制（伤害加倍），0.5表示被克制（伤害减半），未列出的默认1.0
    attribute_restraint = {
        "water": {
            "fire": 2, "stone": 2, "grass": 2,  # 克制
            "fire": 0.5, "lightning": 0.5       # 被克制（原数据中火同时出现在克制和被克制，这里修正为被克制）
        },
        "fire": {
            "ice": 2, "grass": 2, "dark": 2,    # 克制
            "water": 0.5, "stone": 0.5          # 被克制
        },
        "ice": {
            "water": 2, "wind": 2, "grass": 2,  # 克制
            "fire": 0.5, "stone": 0.5           # 被克制
        },
        "lightning": {
            "water": 2, "wind": 2, "sky": 2,    # 克制
            "stone": 0.5, "dark": 0.5           # 被克制
        },
        "wind": {
            "fire": 2, "dark": 2, "sky": 2,     # 克制
            "stone": 0.5, "ice": 0.5            # 被克制
        },
        "dark": {
            "lightning": 2, "wind": 2, "grass": 2,  # 克制
            "light": 0.5, "fire": 0.5               # 被克制
        },
        "light": {
            "dark": 2, "ice": 2, "sky": 2,     # 克制
            "dark": 0.5, "stone": 0.5          # 被克制（原数据中dark同时出现在克制和被克制，这里修正为被克制）
        },
        "grass": {
            "water": 2, "stone": 2, "sky": 2,  # 克制
            "fire": 0.5, "ice": 0.5, "dark": 0.5  # 被克制
        },
        "stone": {
            "ice": 2, "wind": 2, "light": 2,   # 克制
            "water": 0.5, "grass": 0.5, "lightning": 0.5  # 被克制
        },
        "sky": {
            "water": 2, "fire": 2, "stone": 2,  # 克制
            "lightning": 0.5, "wind": 0.5, "grass": 0.5  # 被克制
        }
    }

    @classmethod
    def get_restraint_multiplier(cls, attacker_attr, defender_attr):
        if attacker_attr not in all_attributes or defender_attr not in all_attributes:
            raise ValueError(f"Attribute not found uer_attr:{attacker_attr} defender_attr:{defender_attr} type:{type(defender_attr)}")
        multiplier = cls.attribute_restraint[attacker_attr].get(defender_attr, 1.0)
        return multiplier